import { useMemo, useState } from "react";
import { useAppSelector } from "../app/hooks";

export function useCar() {
	const car = useAppSelector(state => state.car.car);

	const totalCount = car.reduce((p, n) => {
		return p + n.count
	}, 0)

	const totalCheckPrice = car.reduce((p, n) => {
		return n.isChecked ? p + n.count * n.price : p
	}, 0)


	const isAllCheck = car.every(v => v.isChecked)

	return { totalCount, totalCheckPrice, isAllCheck }
}